using UnityEngine;

namespace MLTimeline
{
    [System.Serializable]
    public abstract class TweenClip : IClip
    {
        public float startTime;
        public float endTime;
        private int _startFrame;
        private int _endFrame;
        public int StartFrame => _startFrame;
        public int EndFrame => _endFrame;

        public void Initialize(Timeline timelineData)
        {
            //根据插入的起始时间和结束时间计算当前起始帧和结束帧
            _startFrame = Mathf.CeilToInt(timelineData.frameRate * startTime);
            _endFrame = Mathf.CeilToInt(timelineData.frameRate * endTime);
            OnInitialize(timelineData);
        }

        protected virtual void OnInitialize(Timeline timelineData) { }

        public virtual void Enter() { }

        public virtual void Exit() { }

        public abstract void Evaluate(int frame, float progress, float frameRate);
    }
}